/*
 * cajaSprite.java
 *
 * Created on 29 de diciembre de 2006, 03:02 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package hello;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
/**
 *
 * @author anfeques
 */

public class boxSprite extends Sprite {
    private int delta;
    private int posx;
    private int posy;
    private boolean arriveState=false;
    private int lastposy;
    private int lastposx;
    /**
     * @param imag Imagen apra aplicarle al sprite
     * @param widthFrame ancho de cada frame debe ser multiplo de el ancho de la imagen
     * @param heightFrame alto de cada frame debe ser multiplo de el alto de la imagen
     */
    public boxSprite(Image imag, int widthFrame, int heightFrame) {        
        super(imag, widthFrame, heightFrame);
        this.defineReferencePixel(widthFrame/2,heightFrame/2);        
    }    
    
    public void moveVertical(int dir){
        this.setLastPosition();
        posy+=dir*delta;
        this.setPosition(posx, posy);        
    }
    
    public void moveHorizontal(int dir){
        this.setLastPosition();
        posx+=dir*delta;
        this.setPosition(posx, posy);
    }    
    
    //Metodos SET AND GET    
    
    public void setPosicion(int x,int y){
        this.setPosx(x);
        this.setPosy(y);
        this.setPosition(x, y);
    }
    
    public int geWidthFrame(){
        return this.getWidth();
    }
    
    public int getHeightFrame(){
        return this.getHeight();
    }
    
    public void setArrived(boolean llego){
        this.arriveState=llego;
    }
    
    public int getDelta() {
        return delta;
    }
    
    public void setDelta(int delta) {
        this.delta = delta;
    }
    
    public int getPosx() {
        return posx;
    }
    
    public void setPosx(int posx) {
        this.posx = posx;
    }
    
    public int getPosy() {
        return posy;
    }
    
    public void setPosy(int posy) {
        this.posy = posy;
    }
    
    public int getLastPosy() {
        return this.lastposy;    }
    
    public int getLastPosx() {
        return this.lastposx;
    }
    
    private void setLastPosx() {
        this.lastposx = this.posx;
    }
    
    private void setLastPosy() {
        this.lastposy =this.posy;
    }
    
    private void setLastPosition() {
        setLastPosx();
        setLastPosy();
    }
    
    public boolean getState(){
        return this.arriveState;
    }
}
